#ifndef KEY_RGB_RELAY_H
#define KEY_RGB_RELAY_H

#include <QWidget>
#include <QDebug>
#include <stdio.h>
#include <string.h>
#include "serial_port/serial_tx_thread.h"
#include "serial_port/serial_rx_thread.h"
#include <QtEndian>

typedef struct rgb_relay
{
    unsigned short dev_type;
    unsigned short relay_onoff;
    short r_pwm_duty;
    short g_pwm_duty;
    short b_pwm_duty;
}rgb_relay_t;

//设备类型
enum
{
    DEV_TYPE_NONE = 0,
    DEV_TYPE_WIRELESS_BOARD,
    DEV_TYPE_KEY_RGB_RELAY,
    DEV_TYPE_DHT11_OLED,

    DEV_TYPE_ALL
};

#define TERMINAL_DEV_TYPE      DEV_TYPE_KEY_RGB_RELAY

class Key_RGB_Relay : public QWidget
{
    Q_OBJECT

public:
    explicit Key_RGB_Relay(Serial_Tx_Thread *tx_thread , Serial_Rx_Thread *rx_thread);
    ~Key_RGB_Relay();

    void set_r_brightness(unsigned short dev_id,unsigned short value);
    void set_g_brightness(unsigned short dev_id,unsigned short value);
    void set_b_brightness(unsigned short dev_id,unsigned short value);

    void set_relay_onoff(unsigned short dev_id,bool onoff);

    rgb_relay_t rgb_relay;

signals:
    void signal_write_sp_tx_queue(char *s,unsigned int len);

private slots:

private:

    Serial_Tx_Thread *tx_thread;
    Serial_Rx_Thread *rx_thread;

    void send_rgb_data_to_device(unsigned short dev_id);
};



#endif

